package com.itheima;

import com.itheima.dao.BookDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author: dh
 * @date: 2023-10-21 15:53
 * bean的作用范围Scope。
 */
public class AppForBeanScope {

    public static void main(String[] args) {

        // 1.获得IoC容器.
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        // 2.通过getBean方法来获得bean
        BookDao bookDao1 = (BookDao) ctx.getBean("bookDao");
        BookDao bookDao2 = (BookDao) ctx.getBean("bookDao");
        // 3.打印BookDao。
        System.out.println(bookDao1);
        System.out.println(bookDao2);
    }
}
